package com.example.demo.controller;

import com.example.demo.component.ThreadPoolExecutorTest;
import com.example.demo.entity.Time;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private ThreadPoolExecutorTest executors;

    @RequestMapping("/test")
    public void test(Time time) {
        executors.put(new Runnable() {
            @Override
            public void run() {
                System.out.println(LocalDateTime.now());
            }
        }, time);
        System.out.println(LocalDateTime.now());
    }

    @RequestMapping("/hello")
    public String hello() {
        System.out.println("hello world");
        return "hello world!";
    }
}
